home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sounds Terrific 1
/
Sounds Terrific CD (1994)(Weird Science)(Disc 2 of 2)[!][Amiga-PC].iso
/
modules
/
g
/
greeny1a.mod
< prev
next >
Wrap
Text File
|
1994-08-04
|
9KB
|
330 lines
I tested it on clean source this time. RANQUOTE v2.00...
Greeny #8 @6910
Wed Jan 08 10:31:58 1992
RANDOM MULTI-LINE QUOTES AT MENU PROMPTS
GREENY01.MOD
Version 2.00
Here's a mod that will allow random quotes at each main menu and transfer
menu prompt. It's mostly block read in, and unless you really want to you
won't have to recompile your whole source code.
To edit the entire quote list (add quotes to the list, delete any quote from
the list, or view the entire list) type //QUOTEEDIT from the main menu, or
hit the quote key (") when it's waiting for a caller. It will create and
update a data file called RANQUOTE.DAT, in the gfiles directory.
Unlike version 1.00, this has been tested by installing it into vanilla 4.20
source. (Version 1.00 worked perfectly after two minor bug fixes, which are
both marked.) Also, the functions that are block read in have been
considerably improved since 1.00, but they should have worked all right
before...
To install the mod, do this:
1) Back up your source code. (I use arj a -jm1 source *.c *.h *.prj, in a
batch file that deletes the old source.arj file first. If you prefer
zip or something, it's your choice...)
2) You must prototype the three new functions. The easy way to do this
is to stick them into the beginning of the file BBS.C. Right after the
line #define modem_time 3.5 is a good place. The function prototypes look
like this:
void random_quote();
char *get_random_quote();
void thump();
Just add them into your source code, each on a seperate line.
3) Now find the function "void main()". To do a search in Turbo C, or TC++,
Hit Control-Q Control-F, and type in void main() on the line it gives you.
Near the beginning of void main(), you'll find the following code. Add
the line indicated, and change the other. (== means this line is already
there, ++ means add this line, += means modify the existing line.)
== char *s, s1[81],s2[81];
+= int i,abort=0; /* change from V1.00 */
== long l;
==
== if ((sysstatus_expert & thisuser.sysstatus)==0)
== printmenu(0);
==
== nl();
++ thump(get_random_quote(),&abort);
== nl();
== tleft(1);
4) About one screen down from the last change you should see this. Add the
four lines indicated.
==/**************************************************/
== if (so()) {
++ if (strcmp(s,"QUOTEEDIT")==0) {
++ sysoplog("@ Ran QuoteEdit");
++ random_quote();
++ }
== if (strcmp(s,"BOARDEDIT")==0) {
== sysoplog("@ Ran Boardedit");
== boardedit();
== }
5) Next, search for the function "void dlmainmenu()" and modify the one line
and insert the other line, near the beginning.
== char *s, s1[81],s2[81],ch;
+= int i,i1,i2,abort=0,next; /* change from V1.00 */
== messagerec m;
==
== if ((sysstatus_expert & thisuser.sysstatus)==0)
== if ((sysstatus_expert & thisuser.sysstatus)==0)
== printmenu(3);
==
== nl();
++ thump(get_random_quote(),&abort);
== nl();
== tleft(1);
6) Now search for the function "void getcaller()" and add these three lines.
(They're about three screens down from the beginning...)
== switch(ch) {
++ case '\"':
++ if (ok_local()) random_quote();
++ break;
== case '?':
== if (ok_local()) {
7) Those are all the changes that need to be made to the existing code. Now
we add some new functions. These can be block read in if you don't feel
like typeing them. (To block read something in, hit Control-K Control-R,
tell it the file name, and then hit Control-K Control-H to put the colors
back to normal. Just block read in this entire mod at the end of BBS.C
and delete all the lines before and after the functions. (Control-Y will
delete the line your cursor is currently on.)
/* BEGINNING OF BLOCK READ FOR GREENY'S RANDOM QUOTE MOD */
/* These are all changed from 1.00 */
void random_quote()
{
#define QUOTE_LINES 3
#define QUOTE_SIZE ((80*QUOTE_LINES)+1)
long int f,f1,i,i1,i42,offset;
int abort;
char s[QUOTE_SIZE],s1[100],ch,ch1;
for(i=0; i<QUOTE_SIZE; i++) {
s[i]=0;
}
i=0;
do {
abort=0;
lines_listed=0;
nl();
nl();
prt(5,"Random Quotes - A)dd, L)ist, D)elete, Q)uit :");
ch=toupper(getch());
nl();
switch(ch) {
case 'Q':
return;
case 'L':
nl();
prt(2,"Random Quotes Available");
nl();
prt(2,"-----------------------");
nl();
strcpy(s1,"RANQUOTE.DAT");
if((f=open(s1,O_RDONLY))!=-1) {
lseek(f,0L,SEEK_SET);
i=filelength(f)/QUOTE_SIZE;
if (i) {
for (i1=0,(i=filelength(f)/QUOTE_SIZE); i1<i; i1++) {
lseek(f,((long) (i1*QUOTE_SIZE)),SEEK_SET);
read(f,s,QUOTE_SIZE);
sprintf(s1,"%04d:",i1+1);
if(!abort) {
ansic(4);
pl(s1);
ansic(0);
}
thump(s,&abort);
nl();
}
nl();
close(f);
} else {
close(f);
goto NOPE;
}
} else goto NOPE;
break;
NOPE:
prt(3, "There are no quotes available.");
nl();
break;
case 'A':
nl();
prt(2,"Enter Random Quote...");
nl();
sprintf(s1,"Enter Random quote, %d lines maximum",QUOTE_LINES);
pl(s1);
s1[0]=0;
s[0]=0;
for (i=0; i<3; i++) {
inli(s+strlen(s),s1,i<2 ? QUOTE_SIZE-strlen(s)-5 :
(QUOTE_SIZE-strlen(s)-5>78 ? 78 : QUOTE_SIZE-strlen(s)-5),
i <2 ? 1:0 );
if(s[0]==0) break;
if(strlen(s)>3) {
if(s[strlen(s)-3]!='\n') sprintf(s+strlen(s),"\n%c0",3);
else break;
}
}
if(s[0]==0) {
nl();
prt(3, "Aborted");
nl();
break;
}
strcpy(s1,"RANQUOTE.DAT");
f=open(s1,O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE);
if(filelength(f)) {
lseek(f,-1L,SEEK_END);
read(f,((void *)&ch1),1);
if(ch1==26) lseek(f,-1L,SEEK_END);
}
s[QUOTE_SIZE-1]=0;
write(f,(void *)s,QUOTE_SIZE);
close(f);
break;
case 'D':
prt(6,"Number of quote to delete : ");
mpl(4);
inputl(s,4);
i42=atoi(s);
if(i42<1) break;
strcpy(s1,"RANQUOTE.DAT");
f=open(s1,O_RDWR | O_BINARY);
if(f>-1) {
i1=filelength(f);
if(i42>i1/QUOTE_SIZE) {
close(f);
break;
}
i42--;
lseek(f,(long) (i42 * QUOTE_SIZE), SEEK_SET);
read(f,s,QUOTE_SIZE);
nl();
nl();
thump(s,&abort);
nl();
prt(5,"Delete this Quote ?");
if (yn()) {
if(i42<(i1/QUOTE_SIZE)-1) {
for(i=i42; i<(i1/QUOTE_SIZE)-1; i++) {
lseek(f,(long) (QUOTE_SIZE * (i+1)),SEEK_SET);
read(f,(void *)s,QUOTE_SIZE);
lseek(f,(long) (QUOTE_SIZE * i),SEEK_SET);
write(f,(void *)s,QUOTE_SIZE);
}
}
chsize(f,(long) (i1-QUOTE_SIZE));
pl("Quote deleted");
}
close(f);
}
break;
}
} while (1);
}
char *get_random_quote()
{
long int f,i,i1;
static char s1[QUOTE_SIZE];
char s[100];
s1[0]=0;
strcpy(s,"RANQUOTE.DAT");
if ((f=open(s,O_RDONLY))!=-1)
{
lseek(f,0L,SEEK_SET);
i=filelength(f)/QUOTE_SIZE;
if(i) {
i1=random(i);
lseek(f,(long) (i1 * QUOTE_SIZE),SEEK_SET);
read(f,s1,QUOTE_SIZE);
}
close(f);
}
return s1;
}
void thump(char *s, int *abort)
{
int i=0,what=0,glurk;
while(s[i]) {
if(!(*abort)) {
if(s[i]=='\n') {
glurk=curatr;
ansic(0);
nl();
setc(glurk);
}
else outchr(s[i]);
}
checka(abort,&what);
i++;
}
ansic(0);
}
/* END OF BLOCK READ FOR GREENY'S RANDOM QUOTE MOD */
8) Now save off the file by hitting F2, and compile it. (If you haven't
figured out how to set up a decent project file for F9, figure out how to
do so and in the mean time drop to dos and use random's make file.)
9) Send me some email. I have an account as user #8 at WWIVnet node @6910.
NOTE: you can change color in a quote with the standard CTRL-P sequences. On
every line except the last one this won't shorten the length before it
wordwraps.
ANOTHER NOTE: you can change the maximum number of lines in each quote by
changing the #define QUOTE_SIZE, but you'll have to delete your old
RANQUOTE.DAT file and start a new one if you've already entered a bunch of
quotes of the old size. 3 lines is a good size, especially since the vast
majority of quotes are likely to be one or two lines, and the full amount of
disk space is allocated to store each quote even if you only enter one
letter.
Thanks for being patient about version 2... I'm in college, you know. Takes
up a lot of one's time.
3(GREENY)09
9THE PROMISED LAND Delran NJ 609-764-7144 Reg. #91223
86HOST OF SUB 42 - DEEP THOUGHT: THE INTERNATIONAL MENSA NET0
7USR 38400/HST/HST/V.32/V.32-BIS/LAPM/V.42/V.42-BIS/MNP/ARQ/ASL